#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#define ERROR_CHECK(ret, num, msg) \
    {                              \
        if (ret == num)            \
        {                          \
            perror(msg);           \
            exit(1);               \
        }                          \
    }
int main(int argc, char *argv[])
{

    int fdsrc = open(argv[1], O_RDONLY);
    ERROR_CHECK(-1, fdsrc, "open src");
    char buf = '\0';
    int fddest = open(argv[2], O_CREAT | O_WRONLY, 0664);
    ERROR_CHECK(-1, fddest, "open dest");
    while (read(fdsrc, &buf, 1))
    {

        write(fddest, &buf, 1);//read返回值就是每次返回的大小
    }
    close(fdsrc);
    close(fddest);
    return 0;
}
